home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Online / opennap / resume.c < prev    next >
C/C++ Source or Header  |  2001-06-08  |  1KB  |  62 lines

  1. /* Copyright (C) 2000-1 drscholl@users.sourceforge.net
  2.    This is free software distributed under the terms of the
  3.    GNU Public License.  See the file COPYING for details.
  4.  
  5.    $Id: resume.c,v 1.25 2001/02/15 08:39:45 drscholl Exp $ */
  6.  
  7. #include <stdlib.h>
  8. #include "opennap.h"
  9. #include "debug.h"
  10.  
  11. /* packet contains: <checksum> <filesize> */
  12. HANDLER (resume)
  13. {
  14. #if RESUME
  15.     char   *av[2];
  16.     FLIST  *flist;
  17.     LIST   *ptr;
  18.     DATUM  *d;
  19.     int     fsize;
  20. #endif /* RESUME */
  21.  
  22.     (void) tag;
  23.     (void) len;
  24.     (void) pkt;
  25.     ASSERT (validate_connection (con));
  26.     CHECK_USER_CLASS ("resume");
  27. #if RESUME
  28.     if (split_line (av, sizeof (av) / sizeof (char *), pkt) != 2)
  29.     {
  30.     unparsable (con);
  31.     return;
  32.     }
  33.  
  34.     fsize = atoi (av[1]);
  35.     if (fsize < 1)
  36.     {
  37.     send_cmd (con, MSG_SERVER_NOSUCH, "invalid file size");
  38.     return;
  39.     }
  40.  
  41.     /* search the database for a list of all files which match this hash */
  42.     flist = hash_lookup (MD5, av[0]);
  43.     if (flist)
  44.     {
  45.     for (ptr = flist->list; ptr; ptr = ptr->next)
  46.     {
  47.         d = (DATUM *) ptr->data;
  48.         if (d->size == (size_t) fsize)
  49.         {
  50.         ASSERT (validate_user (d->user));
  51.         send_cmd (con, MSG_SERVER_RESUME_MATCH,
  52.               "%s %u %hu \"%s\" %s %u %hu",
  53.               d->user->nick, d->user->ip, d->user->port,
  54.               d->filename, d->hash, d->size, d->user->speed);
  55.         }
  56.     }
  57.     }
  58. #endif /* RESUME */
  59.  
  60.     send_cmd (con, MSG_SERVER_RESUME_MATCH_END, "");
  61. }
  62.